import axios from '@/utils/axios';
import { getRes } from '@/utils/formatDataFromServer';
import { BaseRes, UsersRes } from './types';

/**
 * 获取所有已经报名的用户
 */
export const getAllUsers = async () =>
  getRes<UsersRes>(await axios.post('/admin/findUserInfo'));

/**
 * 更改用户状态
 * @param openid
 * @param status
 */
export const changeStatus = async (openid: string, status: string) =>
  getRes<BaseRes>(
    await axios.put(`/admin/updateUserStatus/${openid}/${status}`),
  );

/**
 * 获取报名队列
 *  @param direction
 */
export const getLineData = async (direction: string) =>
  await axios.get(`/admin/getWaitQueue/${direction}`);

/**
 * 通知下一位
 * @param direction
 */
export const noticeNext = async (direction: string) =>
  await axios.get(`/admin/getNext/${direction}`);

/**
 * 推送服务
 * @param openid
 */

export const sendMessage = async (openid: string) =>
  await axios.get(`/user/pushMessage`, {
    params: {
      openid,
    },
  });
